package com.ycfmedical.bed.ui.fragment;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.ycfmedical.bed.Constants;
import com.ycfmedical.bed.base.BaseFragmentList;
import com.ycfmedical.bed.bean.ImUser;
import com.ycfmedical.bed.local.DataManager;
import com.ycfmedical.bed.ui.ImActivity;

import java.util.List;

import cn.droidlover.xdroidmvp.kit.Kits;

/**
 * Created by yf on 2017-04-05.
 * 个人中心页面
 */

public class UserCenterFragment extends BaseFragmentList {
    @Override
    public void initData(Bundle savedInstanceState) {
        super.initData(savedInstanceState);
        addLisenter();

    }


    private void addLisenter() {
        fragmentsTab.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                if(Constants.POSITION_CHAT==tab.getPosition()){
                    if(!Kits.Empty.check(ImUser.getInstance().getImAccount()))
                    {
                        ImActivity.launch(getActivity());
                    }
                }

            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {
//                if(Constants.POSITION_CHAT==tab.getPosition()){
//                    if(!Kits.Empty.check(ImUser.getInstance().getImAccount()))
//                    {
//                        ImActivity.launch(getActivity());
//                    }
//                }
            }
        });

    }

    @Override
    protected void addFragmentList(List<Fragment> fragmentList) {
        fragmentList.clear();
        fragmentList.add(UserInfoFragment.newInstance( ));
        fragmentList.add(new BaseStaffFragment(DataManager.getInstance().getUser().getDoctorId(), Constants.TYPE_DOCTOR));
        fragmentList.add(new BaseStaffFragment(DataManager.getInstance().getUser().getNurseId(), Constants.TYPE_NURSE));
        fragmentList.add(new TimerReminderFragment());
        fragmentList.add(new ChatFragment());

    }

    @Override
    protected String[] addTabTitle(String[] titles) {
        titles=new String[]{"用户信息","主治医生", "主管护士", "定时提醒","聊天", };
        return titles;
    }

    public static UserCenterFragment newInstance() {
        return new UserCenterFragment();
    }
}


